﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using WCF.Practice.CustomerHost.Service;

namespace WCF.Practice.CustomerHost.Client
{
    class Program
    {
        static void Main(string[] args)
        {
            //method1:
            var client = new UserServiceClient("UserService");

            //var user = client.GetUser();

            try
            {
                var user = client.GetName("name");
            }
            catch (ArgumentOutOfRangeException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (FaultException<ArgumentOutOfRangeException> e)
            {
                Console.WriteLine(e.Message);
            }
            catch (FaultException<ExceptionDetail> e)
            {
                Console.WriteLine(e.Message);
            }
            catch (FaultException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            //method2:
            //var client = new ChannelFactory<IUserService>().CreateChannel();

            //var user = client.GetUser();





            //Console.WriteLine(user.Name);
            Console.ReadLine();
        }
    }
}
